﻿using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.DirectoryServices;
namespace AuthUser.Web
{
    [ServiceContract(Namespace = "")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class Service1
    {
        [OperationContract]
        public void DoWork()
        {
            // Add your operation implementation here
            return;
        }
        [OperationContract]
        public bool Login(string servername, string user, string password)
        {
            bool authenticated = false;
            try
            {
                DirectoryEntry entry = new DirectoryEntry(servername, user, password);//(servername, user, password);               
                object nativeObject = entry.NativeObject;
                authenticated = true;           
              
            }
            catch (DirectoryServicesCOMException cex)
            {
              
            }
                
            catch (Exception ex)
            {
               
            }
            return authenticated;
        }
       
    }
}
